<template>
    <view class="flex-col homepage">
        <view class="u-line-1 text">请选择要绑定的就诊人</view>
        <view @click="patientById(patient.id)" class="flex-col wrapper-two" v-for="patient in patient" :key="patient.id" style="margin-top: 5%;">
            <view class="u-line-1 text-five">{{patient.name}}</view>
            <view class="flex-row wraper-row-two">
				<text v-if="patient.relation == '本人'">
					<view class="u-line-1 text-six">本人</view>
				</text>
				<text v-if="patient.relation == '子女'">
					<view class="u-line-1 text-six">子女</view>
				</text>
				<text v-if="patient.relation == '夫妻'">
					<view class="u-line-1 text-six">夫妻</view>
				</text>
				<text v-if="patient.relation == '父母'">
					<view class="u-line-1 text-six">父母</view>
				</text>
				<text v-if="patient.relation == '朋友'">
					<view class="u-line-1 text-six">朋友</view>
				</text>
            </view>
            <view class="u-line-1 text-seven">{{patient.number}}</view>
        </view>
    </view>
</template>
<script>
    export default {
        data() {
            return {
				URL:'http://localhost:9000/',//主域名
				userId:'',
				patient:[]
			}
        },
        methods: {
			
			//绑定住院人
			patientById(id){
				console.log(id)
				uni.navigateTo({
					url:"hospitalView?id="+id
				})
				// uni.request({
				// 	url:this.URL+"user/user/inpatient/hospitalById/"+this.id,
				// 	method:"GET",
				// 	success: (res) => {
				// 		console.log(res)
				// 		if(res.data.code == 20000){
				// 			this.hospital = res.data.data.hospital
				// 			console.log(this.hospital)
				// 		}
				// 	}
				// })
			}

        },
		onLoad(id) {
			this.userId = id.id
			console.log(this.userId)
			// 获取当前用户绑定的就诊人
			uni.request({
				url:this.URL+"user/user/the-patient/patientByUserId/"+this.userId,
				method:"GET",
				success: (res) => {
					console.log(res)
					if(res.data.code == 20000){
						this.patient = res.data.data.patientList
						console.log(this.patient)
					}
				}
			})
		}
    }
</script>
<style lang="scss" scoped>
    /** 全局样式-开始,建议放在公共css样式文件中,比如common.css 或app.vue文件 */

    html,
    body {
        margin: 0;
        width: 100%;
        height: 100%;
        font-size: 16px
    }

    view,
    text,
    image {
        position: relative;
        box-sizing: border-box;
        flex-shrink: 0;
    }

    .flex-col {
        display: flex;
        align-items: flex-start;
        flex-direction: column;
    }

    .flex-row {
        display: flex;
        align-items: flex-start;
    }

    .flex-col .flex-row {
        width: 100%
    }

    /** 全局样式-结束*/

    .homepage {
        padding: 36rpx 19rpx 0rpx 19rpx;

        .text {
            width: 100%;
            margin-bottom: 60rpx;
            font-size: 32rpx;
        }

        .wrapper {
            width: 100%;
            margin-bottom: 20rpx;
            padding: 34rpx 0rpx 24rpx 40rpx;
            border-radius: 10rpx;
            background: #f5f9ff;

            .wraper-row {
                width: 166rpx;
                justify-content: space-between;
                margin-bottom: 32rpx;

                .text-two {
                    width: 82rpx;
                }

                .box {
                    width: 78rpx;
                    justify-content: center;
                    padding-top: 2rpx;
                    border-radius: 20rpx;
                    background: #e2edfe;

                    .text-three {
                        width: 58rpx;
                        font-size: 28rpx;
                        color: #7c9cff;
                    }
                }
            }

            .text-four {
                width: 278rpx;
                font-size: 24rpx;
                color: #bbbbd6;
            }
        }

        .wrapper-two {
            width: 100%;
            padding: 34rpx 0rpx 24rpx 40rpx;
            border-radius: 10rpx;
            background: #f5f9ff;

            .text-five {
                width: 82rpx;
                margin-bottom: -38rpx;
            }

            .wraper-row-two {
                width: 78rpx;
                justify-content: center;
                margin: 0rpx 0rpx 32rpx 88rpx;
                padding-top: 2rpx;
                border-radius: 20rpx;
                background: #e2edfe;

                .text-six {
                    width: 58rpx;
                    font-size: 28rpx;
                    color: #7c9cff;
                }
            }

            .text-seven {
                width: 278rpx;
                font-size: 24rpx;
                color: #bbbbd6;
            }
        }
    }
</style>